#pragma once

#include "../../inc/TopoDS/OMIT_MeshForwardDecl.h"

namespace OMIT_NAMESPACE
{
	template<typename Traits>
	class TFace
    {
	public:
		using TV = MeshTraits_V<Traits>;
		using TE = MeshTraits_E<Traits>;
		using TF = MeshTraits_F<Traits>;
		using TH = MeshTraits_H<Traits>;

	public:
		TH* HalfEdge() noexcept { return _h; }
		const TH* HalfEdge() const noexcept { return const_cast<TFace*>(this)->HalfEdge(); }

		void SetHalfEdge(TH* h) noexcept { _h = h; }
		void Reset() noexcept { _h = nullptr; }

		// 位于曲面边界上的面指针为空指针
		static bool IsBoundary(const TF* f) noexcept { return f == nullptr; }

		// 面的度，为边数或者顶点数
		std::size_t Degree() const noexcept { assert(HalfEdge()); return HalfEdge()->FaceDegree(); }

        // 按照半边的后继方式访问多边形上从半边 HalfEdge() 到 HalfEdge() 的环路
		H_NextView<false, Traits> AdjHalfEdges() { return HalfEdge()->NextLoop(); }
		H_NextView<true, Traits> AdjHalfEdges() const { return HalfEdge()->NextLoop(); }

	private:
		friend TMesh<Traits>;

		TH* _h{ nullptr };
    };
}

#include "../../inc/TopoDS/OMIT_MeshFace.inl"